<!--

    This file is part of kanji-portal.com.

    kanji-portal.com is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    kanji-portal.com is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with kanji-portal.com.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (c) 2008-2009 Nicolas Radde <nicolas@radde.org>

-->
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:a="http://richfaces.org/a4j"
                template="#{theme.template}">

    <!-- content -->
    <ui:define name="content">
        <div class="section">
            <fieldset>
                <legend>#{messages['dictionary.search.text.search']}</legend>

                <h:form id="searchCriteria">
                    <h:inputText id="searchString" value="#{dictionarySearch.searchString}" style="width: 165px;">
                        <a:support event="onkeyup" actionListener="#{dictionarySearch.find}" reRender="searchResults"/>
                    </h:inputText>
                    <a:commandButton id="search" value="#{messages['dictionary.search.acb.search']}"
                                     action="#{dictionarySearch.find}"
                                     reRender="searchResults"/>
                    <a:status>
                        <f:facet name="start">
                            <h:graphicImage value="#{theme.spinner}"/>
                        </f:facet>
                    </a:status>
                    <a:outputPanel id="messages">
                        <h:messages/>
                    </a:outputPanel>
                    <br/>
                    <s:div id="advancedSearch" rendered="false">
                        <h:outputLabel for="pageSize">#{messages['dictionary.search.hol.pageSize']}</h:outputLabel>
                        <h:selectOneMenu value="#{dictionarySearch.pageSize}" id="pageSize">
                            <f:selectItem itemLabel="5" itemValue="5"/>
                            <f:selectItem itemLabel="10" itemValue="10"/>
                            <f:selectItem itemLabel="20" itemValue="20"/>
                        </h:selectOneMenu>
                    </s:div>
                </h:form>
            </fieldset>
        </div>
        <br/>
        <h:form id="entries">
            <a:outputPanel id="searchResults">
                <div class="section">
                    <h:outputText value="#{messages['dictionary.search.hot.noentries']}"
                                  rendered="#{entries != null and entries.size()==0}"/>
                    <table>
                        <ui:repeat var="dic" value="#{entries}">
                            <ui:repeat var="trans" value="#{dic.translations}">
                                <tr>
                                    <td>
                                        <a:outputPanel
                                                rendered="#{trans.language.codeIso63901 == localeSelector.language}">
                                            <s:link view="/dictionary/view.seam" propagation="none"
                                                    value="#{trans.dictionary.kanji}">
                                                <f:param name="dataModelSelection"/>
                                                <f:param name="entryId" value="#{trans.dictionary.id}"/>
                                            </s:link>
                                            <h:outputText rendered="#{trans.dictionary.kana != null}"
                                                          value=" 「#{trans.dictionary.kana.replace('.', '')}」"/> : #{trans.description.replace("|", "; ")}. #{trans.detail}
                                        </a:outputPanel>
                                    </td>
                                </tr>
                            </ui:repeat>
                        </ui:repeat>
                    </table>
                    <ui:remove>
                        <!--
                        <h:dataTable id="entries" value="#{entries}" var="dic" rendered="#{entries.rowCount>0}">
                            <h:column>
                                <f:facet name="header">#{messages['dictionary.search.hdt.kanjis.header.kanji']}</f:facet>
                                <s:link view="/dictionary/view.seam" propagation="none" value="#{dic.kanji}">
                                    <f:param name="dataModelSelection"/>
                                    <f:param name="entryId" value="#{dic.id}"/>
                                </s:link>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{messages['dictionary.search.hdt.kanjis.header.kana']}</f:facet>
                                #{dic.kana.replace(".", "")}
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{messages['dictionary.search.hdt.kanjis.header.description']}</f:facet>
                                #{dic.description.replace("|", "; ")}
                            </h:column>
                        </h:dataTable>
                        -->
                    </ui:remove>
                    <a:commandLink value="#{messages['dictionary.search.acl.nextPage']}"
                                   action="#{dictionarySearch.nextPage}"
                                   rendered="#{dictionarySearch.nextPageAvailable}" reRender="searchResults"/>
                </div>
            </a:outputPanel>
        </h:form>

    </ui:define>

</ui:composition>
